#include <bits/stdc++.h>
#include <string>
using namespace std;
const int N = 100;
int diagram[N][N];
int main()
{
    int n,m,s,e;
    cin >> n >> m;
    while(m--){
        cin >> s >> e;
        diagram[s][e] = 1;
    }
    // degree: 入度  vis[i]：i是否被访问过
    int degree[n+1] = {0},vis[n+1] = {0};
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(diagram[j][i]) degree[i]++;
        }
    }
    while(true){
        bool findPoint = false;
        for(int i=1;i<=n;i++){
            if(degree[i]==0 && vis[i] == 0){
              vis[i] = 1;
              for(int j=1;j<=n;j++){
                if(diagram[i][j]) degree[j]--;
              }
              findPoint = true;
            }
        }
        if(!findPoint) break;
    }
    for(int i=1;i<=n;i++){
        if(degree[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}
/*
4 5
1 2
1 3
2 4
3 4
4 1
*/
/*
4 5
1 2
1 3
2 4
3 4
4 4
*/